www.gusucode.com > VC++ 打飞机游戏-源码程序 > VC++ 打飞机游戏-源码程序\code\src\SettingPage.cpp

    //Download by http://www.NewXing.com
// SettingPage.cpp : implementation file
//

#include "stdafx.h"
#include "fighter.h"
#include "SettingPage.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CSettingPage property page

IMPLEMENT_DYNCREATE(CSettingPage, CPropertyPage)

CSettingPage::CSettingPage() : CPropertyPage(CSettingPage::IDD)
{
	//{{AFX_DATA_INIT(CSettingPage)
	m_strBossFile = _T("");
	m_bShortcut = TRUE;
	m_bSound = TRUE;
	m_strShortcutName = _T("打飞机");
	//}}AFX_DATA_INIT
}

CSettingPage::~CSettingPage()
{
}

void CSettingPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSettingPage)
	DDX_Text(pDX, IDC_BOSS_FILE, m_strBossFile);
	DDX_Check(pDX, IDC_SHORTCUT, m_bShortcut);
	DDX_Check(pDX, IDC_SOUND, m_bSound);
	DDX_Text(pDX, IDC_SHORTCUT_NAME, m_strShortcutName);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSettingPage, CPropertyPage)
	//{{AFX_MSG_MAP(CSettingPage)
	ON_BN_CLICKED(IDC_BROWSE_BOSS_FILE, OnBrowseBossFile)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSettingPage message handlers


void CSettingPage::OnBrowseBossFile() 
{
	// TODO: Add your control notification handler code here
	CFileDialog dlgFile(TRUE, "*.cpp", NULL, 
		OFN_ALLOWMULTISELECT|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST|OFN_HIDEREADONLY,
		_T("C++ Files (*.cpp)|*.cpp|Text Files (*.txt)|*.txt|All Files (*.*)|*.*||"), this);

	if(dlgFile.DoModal()!=IDOK)
		return;

	m_strBossFile = dlgFile.GetPathName();
	UpdateData(FALSE);
}

BOOL CSettingPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	char pathname[_MAX_PATH];
	char drive[_MAX_DRIVE];
	char dir[_MAX_DIR];
	char fname[_MAX_FNAME];
	char ext[_MAX_EXT];

	GetModuleFileName(NULL, pathname, _MAX_PATH);
	_splitpath(pathname, drive, dir, fname, ext);
	m_strBossFile.Format("%s%sSetting.txt", drive, dir);

	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}